<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 实现一个 trim 函数，如同原生的 Array.prototype.trim，以下有两个测试用例 -->

    <!-- // hello

    //=> hello -->
    <script>
        const trim = (str) => {
            let newStr = ''
            for (const element of str) {
                if (!(element === ' ' || element === '\t' || element === '\n')) {
                    newStr += element
                }
            }
            return newStr
        }
        console.log(trim(" hello \t\n"));
        console.log(trim(" hello "));
        console.log('hello');


    </script>
</body>

</html>